<script setup>
import { ref } from 'vue'
import deviceForm from './deviceForm.vue'
defineProps({
    visible: {
        type: Boolean,
        required: true,
    },
    deviceId: {
        type: String,
        default: '',
    },
    title: {
        type: String,
        default: '',
    },
    deviceClassId: {
        type: String,
        default: '',
    },
    deviceClassify: {
        type: String,
        default: '',
    },
})
const emits = defineEmits(['update:visible', 'success'])
function closeAction() {
    emits('update:visible', false)
}
const deviceFormRef = ref()
function submitAction() {
    deviceFormRef.value.submitAction()
}
function onSubmitSuccess() {
    emits('success')
    closeAction()
}
</script>

<template>
    <el-dialog
        :model-value="visible"
        :title="title"
        width="600px"
        :draggable="true"
        @close="closeAction"
    >
        <deviceForm
            ref="deviceFormRef"
            :deviceClassify="deviceClassify"
            :deviceClassId="deviceClassId"
            :deviceId="deviceId"
            @success="onSubmitSuccess"
        ></deviceForm>
        <template #footer>
            <span class="dialog-footer">
                <el-button @click="closeAction">取消</el-button>
                <el-button type="primary" @click="submitAction">
                    提交
                </el-button>
            </span>
        </template>
    </el-dialog>
</template>

<style lang="scss" scoped></style>
